package com.liu.seckill.controller;

import com.liu.seckill.service.IUserService;
import com.liu.seckill.vo.LoginVo;
import com.liu.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @ClassName LoginController
 * @Author ：name
 * @Date ：2022-02-14 17:02
 * @Description：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    private IUserService userService;

      /**
      * 跳转登录页
      *
      * @return
      */
      @RequestMapping("/toLogin")
    public String toLogin(){
          return "login";
      }

    /**
      * 登录
      * @return
      */
    @RequestMapping("/doLogin")
    @ResponseBody
    public RespBean doLogin(HttpServletRequest request, HttpServletResponse
            response, @Valid LoginVo loginVo) {


    return userService.login(request,response,loginVo);

    }

}
